package appletTwo;

import globalCode.ConnThread;
import globalCode.GroupConnections;

import javax.swing.JProgressBar;

public class GroupConnectionsThread extends ConnThread {
	boolean stopBool = false;
	GroupConnections groupCon;
	JProgressBar progress;
	GCSTestApplet parentApplet;
	public GroupConnectionsThread(GCSTestApplet gcta, GroupConnections gc, JProgressBar jp){
		parentApplet = gcta;
		groupCon = gc;
		progress = jp;
	}
	
	public void end(){
		stopBool = true;
	}
	
	public void run(){
		long timeOrig = System.currentTimeMillis();
		int i = 0;
		int max = groupCon.getIDs().size()-2;
		progress.setMaximum(max);
		while(!stopBool && i!=-1){
			i = groupCon.splitGetCons(this);
			progress.setValue(i);
		}
		long timeEnd = System.currentTimeMillis();
		System.out.println("TIME:"+ (timeEnd-timeOrig));
		if(stopBool)
			return;
		parentApplet.display(groupCon.getRankings());
		
	}
}
